export default {
  // 获取本地数据
  getData() {
    let data = localStorage.getItem('myLike')
    if (data) {
      data = JSON.parse(data)
      return data
    }
    return []
  },
  setData(curLike) {
    // curLike: 当前需要收藏的菜谱
    let data = this.getData()
    let arr = data.filter((item) => item.id == curLike.id)
    // 判断当前菜谱的收藏状态
    if (arr.length > 0) return
    data.push(curLike)
    localStorage.setItem('myLike', JSON.stringify(data))
  }
}
